//package com.cssy.yd.basic.web;
//
//
//import java.util.ArrayList;
//import java.util.Date;
//import java.util.List;
//import java.util.Map;
//
//import javax.annotation.Resource;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
//import org.springframework.stereotype.Controller;
//import org.springframework.ui.Model;
//import org.springframework.validation.BindingResult;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//
//import com.cssy.base.web.BaseController;
//import com.cssy.base.web.BodyMsg;
//import com.cssy.yd.basic.entity.BasicMaterialstypeDO;
//import com.cssy.yd.basic.service.IBasicMaterialstypeService;
//import com.plat.exception.SyBaseException;
//import com.plat.helper.JqGridHandler;
//import com.plat.helper.SearchConditions;
//import com.plat.helper.SearchResult;
//import com.plat.util.DateUtils;
//import com.plat.util.GlobalResLoader;
//import com.plat.util.IDCodeTypeUtil;
//import com.plat.util.OperationFlag;
//import com.plat.util.SessionUtil;
//import com.plat.util.json.AjaxUtil;
//import com.plat.util.json.OutJsonGrid;
//import com.yuendong.sy.po.code.SyCode;
//import com.yuendong.sy.service.code.SyCodeType;
//import com.yuendong.sy.service.code.impl.SyCodeService;
//@Controller
//@RequestMapping("/yd/basic/matertype")
//public class BasicMaterialstypeController extends BaseController<BasicMaterialstypeDO>{
//	private static final String itemtype="材料分类";
//	private static final String chenpin="成品";
//	private static final String MANAGER = "/yd/basic/materials/MaterialstypeManager";//列表页面
//	private static final String MANAGER2 = "/yd/basic/materialsEndProduct/MaterialsEndProductManager";
//	private static final String EIDT = "/yd/basic/materials/MaterialstypeOperation";//添加、修改、显示页面
//	private static final String MANAGERBROWSE = "/yd/basic/materialsBrowse/MaterialsBrowseManager";//列表页面
//	private static final String MANAGERBROWSE2 = "/yd/basic/materialsEndProductBrowse/MaterialsEndProductBrowseManager";//列表页面
//	
//	
//	@Resource(name="basicmatertypeService")
//	private IBasicMaterialstypeService basicmatertypeService;
//	
//	@Resource(name="syCodeService")
//	private SyCodeService syCodeService;
//	
//
//	public String manager(HttpServletRequest request, Model model)
//			throws Exception {
//		return MANAGER;
//	}
//	@RequestMapping("/managerEndProduct")
//	public String manager2(HttpServletRequest request, Model model)
//			throws Exception {
//		return MANAGER2;
//	}
//	@RequestMapping("/managerBrowse")
//	public String managerBrowse(HttpServletRequest request, Model model)
//			throws Exception {
//		return MANAGERBROWSE;
//	}
//	@RequestMapping("/managerEndProductBrowse")
//	public String managerBrowse2(HttpServletRequest request, Model model)
//			throws Exception {
//		return MANAGERBROWSE2;
//	}
//	
//	@Override
//	public void list(HttpServletRequest request, HttpServletResponse response)
//			throws Exception {
////		JqGridHandler hander=new JqGridHandler(request);
////		SearchConditions scs = new SearchConditions();
////		scs.setRemovedProperty(null);//判断是否有删除标识
////		hander.getWheres(scs);	
////		SearchResult result=	basicmatertypeService.findListByExample(scs);
////		OutJsonGrid out=new OutJsonGrid(result);
////		out.printJSon(response);
//		
//	}
//
//	@Override
//	public String operationForm(HttpServletRequest request,@PathVariable String id,
//			@PathVariable String flag, Model model) throws Exception {
//		
//		return null;
//	}
//	
//	
//	
//	@Override
//	public Map<String, Object> save(HttpServletRequest request,
//			BasicMaterialstypeDO curAP, BindingResult result, Model model)
//	{
//		return null;
//		
//	}
//		
//
//	@Override
//	public Map<String, Object> delete(HttpServletRequest request,
//			HttpServletResponse response, Model model) throws Exception {
//		
//		return null;
//	}
//
//	@RequestMapping(value = "/tree")
//	public void treelist(HttpServletRequest request,HttpServletResponse response)throws Exception{
//		String tr=null;
//		List<BasicMaterialstypeDO> list =basicmatertypeService.findAll(itemtype);
//		int jd = -1;
//		if(list.size()>0){
//			tr=tree(list,jd);
//		}else{
//			String id=IDCodeTypeUtil.getId();
//			StringBuffer sf =new StringBuffer();
//			sf.append("[");
//			for(int i=0;i<list.size();i++){
//				sf.append("{");
//				sf.append("\"text\":").append("\"").append(itemtype).append("\"").append(",").append("\"id\":").append("\"").append(id).append("\"");
//				sf.append("}");
//			}
//			sf.append("]");
//			tr=sf.toString();
//			BasicMaterialstypeDO itemype =new BasicMaterialstypeDO();
//			itemype.setCode(syCodeService.getCode("PA","PA",SyCode.DATE_YYMM,5));
//			itemype.setName(itemtype);
//			itemype.setId(id);
//			basicmatertypeService.save(itemype, SessionUtil.getUser(request));
//			
//		}
//		AjaxUtil.printJSonArr(response, tr);
//	}
//	
//    /**
//     * 自调函数 生成tree数据
//     **/
//	private String  tree(List<BasicMaterialstypeDO> list,int jd) throws SyBaseException {
//		List<BasicMaterialstypeDO> list1 =null;
//		StringBuffer sf =new StringBuffer();
//		sf.append("[");
//		for(int i=0;i<list.size();i++){
//			if(itemtype.equals(list.get(i).getParentname())&&chenpin.equals(list.get(i).getName())){
//				continue;
//			}
//			if(i==0){
//				jd=jd+1;
//			}
//			sf.append("{");
//			sf.append("\"text\":").append("\"").append(list.get(i).getName()).append("\"").append(",").append("\"id\":").append("\"").append(list.get(i).getId()).append("\"").append(",").append("\"jd\":").append("\"").append(jd).append("\"");
//			list1 =basicmatertypeService.findAllPa(list.get(i).getId());
//			if(list1.size()>0){
//				sf.append(",").append("\"children\":");
//				sf.append(tree(list1,jd));
//			}
//			if(i==(list.size()-1)){
//				sf.append("}");
//			}else{
//				sf.append("},");
//			}
//		}
//		sf.append("]");
//		return sf.toString();
//	}
//}
